package cn.yonyong.base.project.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Describtion logback 日志测试Controller类
 * @Author yonyong
 * @Date 2019/9/16 9:45
 * @Version 1.0.0
 **/
@Api(value = "/main", tags = "logback日志测试")
@RestController
@RequestMapping("logback")
public class LogbackTestController {

    private final static Logger logger = LoggerFactory.getLogger(LogbackTestController.class);

    @ApiOperation(value = "日志处理off")
    @RequestMapping(value = "off", method = RequestMethod.GET , produces = "application/json;charset=utf-8")
    public String off (){
        return "处理off";
    }
    @ApiOperation(value = "日志处理error")
    @RequestMapping(value = "error", method = RequestMethod.GET, produces = "application/json;charset=utf-8")
    public String error () throws Exception {
        logger.error("test--error");
      return "处理error";
    }

    @ApiOperation(value = "日志处理warn")
    @RequestMapping(value = "warn", method = RequestMethod.GET,produces = "application/json;charset=utf-8")
    public String warn (){
        logger.warn("test--warn");
        return "处理warn";
    }

    @ApiOperation(value = "日志处理info")
    @RequestMapping(value = "info",method = RequestMethod.GET,produces = "application/json;charset=utf-8")
    public String info (){
        logger.info("test--info");
        return "处理info";
    }

    @ApiOperation(value = "日志处理debug")
    @RequestMapping(value = "debug", method = RequestMethod.GET, produces = "application/json;charset=utf-8")
    public String debug (){
        logger.debug("test--debug");
        return "处理debug";
    }

    @ApiOperation(value = "日志处理trace")
    @RequestMapping(value = "trace", method = RequestMethod.GET,produces = "application/json;charset=utf-8")
    public String trace (){
        logger.trace("test--trace");
        return "处理trace";
    }
}
